<template>
	<view class=" bg-white">
		<view class="cu-bar ">
			<view class="action">
				<text class="cuIcon-titles text-blue "></text> 反馈列表
			</view>
		</view>
		
		<view class="cu-list menu" >
			<view class="cu-item arrow" v-for="(item, index) in feedbackList" @click="gotoDetail(item.id)">
				<view class="content padding-tb-sm">
					<view class="flex">
						反馈类型：<DictTag :options="feedbackTypeOptions" :value="item.feedbackType" />
					</view>
					<view class="flex">
						{{item.feedbackTitle}}
					</view>
					
					<view class="text-gray text-sm">
						反馈时间：{{item.createTime}}
					</view>
				
				</view>
				<view class="action">
					<view class="cu-tag badge bg-white margin">
						<DictTag :options="feedbackStatusOptions" :value="item.feedbackStatus"/>
					</view>
				</view>
			</view>
		</view>
				
		<u-empty mode="list" text="暂无反馈内容" v-if="feedbackList.length == 0">
			<view class="padding margin">
				<button class="cu-btn bg-green" @click="gotoFeedback()">立即反馈</button>
			</view>
		</u-empty>
	</view>
</template>

<script>
	
	import { feedbackList } from '@/api/cms.js'
	import { getDictData } from '@/api/api.js'
	
	export default {
		data() {
			return {
				feedbackList: [], // 反馈列表
				
				feedbackTypeOptions: [], // 反馈类型选项
				feedbackStatusOptions: [], // 反馈状态选项
			}
		},
		onShow() {
			this.getFeedbackList();
			this.getDictData();
		},
		methods: {
			// 获取反馈列表
			getFeedbackList() {
				uni.showLoading();
				feedbackList().then(res => {
					this.feedbackList = res.data
					uni.hideLoading();
				})
			},
			
			// 跳转反馈页面
			gotoFeedback() {
				uni.$u.route({url : '/pages/mine/feedback/feedback'})
			},
			
			// 跳转反馈详情
			gotoDetail(feedbackId) {
				uni.$u.route({
					url: 'pages/mine/feedback/feedbackDetail',
					params: {
						id: feedbackId
					}
				})
			},
			// 获取字典数据
			getDictData() {
				getDictData({
					dictType: "cms_feedback_type"
				}).then(res => {
					this.feedbackTypeOptions = res.data;
				})
				
				getDictData({
					dictType: "cms_feedback_status"
				}).then(res => {
					this.feedbackStatusOptions = res.data;
				})
			},
		}
	}
</script>

<style>

</style>
